﻿using System;

using Microsoft.Xna.Framework;
using OakEngine.AI.Dynamic_Steering_Behavior;
using OakEngine.AI.Steering;

namespace OakEngine.AI.Flocking
{
   public class Oak_Alignment : Oak_FlockSteeringBehavior
    {

        public override void UpdateSteeringMovement(Oak_Steering steer)
        {
            int count = this.Flock.SetArea(BehaviorAgent, FlockSize, MinFotProduct);

            if (count <= 0)
                return;

            Vector2 velocity = Flock.GetAverageDirection();

            steer.ForwardVector = velocity - BehaviorAgent.Direction;
            if (OakEngine.AI.Tools.OAK_AITools.SquareMagnitude(steer.ForwardVector) > Speed*Speed)
            {
                steer.ForwardVector = Vector2.Normalize(steer.ForwardVector);
                steer.ForwardVector *= Speed;
            }
        }
    }
}
